from utils.parse_json import load_jsonl_file


results = load_jsonl_file('/Users/wangziqi/Documents/scientific/HIL/hil/data/generated_tests/extend/1113_2127_deepseek-70b.jsonl')
ground_truth = load_jsonl_file('/Users/wangziqi/Documents/scientific/HIL/hil/data/preprocessed_data/all_test_cases_detailed.jsonl')

all_results = {}
for result in results:
    case_id = result['case_id']
    if result['test_level'] == '基础':
        test_level = '扩展'
    else:
        test_level = result['test_level']
    if all_results.get(case_id) is None:
        all_results[case_id] = {
            '冒烟': {
                '生成': [],
                '正确': [],
            },
            '扩展': {
                '生成': [],
                '正确': [],
            }
        }
    all_results[case_id][test_level]['生成'].append(result)

new_results = {}
for result in ground_truth:
    case_id = result['case_id']
    if not result.get('extend_tests'):
        continue
    if case_id not in all_results:
        continue
    new_results[case_id] = all_results.get(case_id)
    for basic_test in result['basic_tests']:
        new_results[case_id]['冒烟']['正确'].append(basic_test)
    for extend_test in result['extend_tests']:
        new_results[case_id]['扩展']['正确'].append(extend_test)

with open('1113_2127_deepseek-70b_results_processed.json', 'w', encoding='utf-8') as f:
    import json
    json.dump(new_results, f, ensure_ascii=False, indent=2)

a = 1   